//导航功能
;(function(){
	var nav = document.querySelectorAll(".cho-nav>li");
	for(var i=0,j=nav.length;i<j;i++){
		(function(){
			var that = nav[i];
			var kk = 1;
			var icon = that.getElementsByTagName('span')[0];
			if(i==0){
				var ul = nav[0].getElementsByTagName('ul')[0];
				var txt = '';
				nav[0].addEventListener('click',function(event){
					if(icon.className == 'active'){
						icon.className = 'unactive';
						txt = event.target.innerHTML;
						ul.style.display = 'none';
					}else{
						icon.className = 'active';
						ul.style.display = 'block';
						txt = '片区'
					}
					icon.innerHTML = txt;
				});
			}
			nav[i].addEventListener('click',function(){
				if(icon.className.indexOf('up')>-1){
					icon.className = icon.className.replace('up','down');
				}else if(icon.className.indexOf('down')>-1){
					icon.className = icon.className.replace('down','up');
				}
			});
		})();
	}
})();

//星星评分功能
;(function(){
	var allStars = document.querySelectorAll('.sch-info-star');
	for(var i=0,j=allStars.length;i<j;i++){
		var star = allStars[i];
		var stars = star.getElementsByTagName('span');
		var num = star.dataset.star;
		console.log(1);
		for(var ii=0,jj=stars.length;ii<jj;ii++){
			if(num<=ii){
				stars[ii].className = "mui-icon mui-icon-star";
			}else if(num<ii+1){
				stars[ii].className = "mui-icon mui-icon-starhalf";
			}else{
				stars[ii].className = "mui-icon mui-icon-star-filled";
			}
		}
	}
})();